<h2>Databases</h2>

<nav>
    <ul class="tab-switch">
        <li><a id="crud_data" href="#tab1" class="default-tab">View Entries</a></li>
        <li><a id="crud_new" href="#tab2">New</a></li>
    </ul>
</nav>


<script type="text/javascript">

var defSelected = $("#crud_data");

setDefaultSelected = function() {
	$(".tab-switch a").parent().siblings().find('a').removeClass("current");
    $(defSelected).addClass("current");
}

$(document).ready(function(){

    // redraw table
    $("#crud_data").click(function(){
      editing = false;
      tableReload();
      $('div.formError').remove();
    });

    // request forms
    $("#crud_new").click(function(){
        $('#tab2-content').empty();
    	defSelected = this;
      if(editing == false) {
        toggleLoading();
        $.ajax({
            url: '<?php echo url_for($sf_context->getModuleName()."/ajaxNewForm") ?>',
            type: 'POST',
            dataType: 'html',
            success: function(response) {
                $("#tab2-content").html(response);
                toggleLoading();
            }
        });
      }
    });


});
</script>